var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');


// 数据库连接
require('./database/connect');
//引入路由
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

var app = express();

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));

//使用解析cookie中间件
//cookieParser()参数一，用来设置签名密钥，可以是一个数组，设置多个。
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);


app.use('/users', usersRouter);

module.exports = app;
